import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 导入组件
import layout from '@/views/layout'
import ArticleDetail from '@/views/article-detail'
import article from '@/views/article'
import collect from '@/views/collect'
import like from '@/views/like'
import user from '@/views/user'

const router = new VueRouter({
  routes: [
    // 从哪个路径，自动重定向到另外一个路径
    // 如果输入/a路径会自动跳转到/article
    // { path:'/a', redirect: '/article' },
    // 下面这条代码毛都不输，就自动跳转到/article
    { path:'/', redirect: '/article' },
    // layout
    {
      name: 'layout',
      path: '/',
      component: layout,
      children: [
        { name: 'article', path: 'article', component: article },
        { name: 'collect', path: 'collect', component: collect },
        { name: 'like', path: 'like', component: like },
        { name: 'user', path: 'user', component: user }
      ]
    },
    // 文章详情
    { name: 'ArticleDetail', path: '/detail/:id', component: ArticleDetail }
  ]
})

export default router
